package cc.beup.common.util;

import java.util.Random;

/**
 * @Author: Byron Bai
 * @Date: 2021/4/18 20:13
 * @Description:
 */
public class RandomUtil {

    private RandomUtil() {
    }

    /**
     * 生成随机数字
     *
     * @param length 随机数长度
     * @Author: Byron Bai
     * @Date: 2021/4/18 20:13
     */
    public static String randomNumber(int length) {
        StringBuilder number = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            number.append(random.nextInt(10));
        }
        return number.toString();
    }

    /**
     * 生成随机数字
     *
     * @param length 随机数长度
     * @Author: xuye
     * @Date: 2021/4/18 20:13
     */
    public static String randomNumberLetter(int length) {
        char[] charPool = {'2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
        StringBuilder numberLetter = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(charPool.length);
            numberLetter.append(charPool[index]);
        }
        return numberLetter.toString();
    }


    public static void main(String[] args) {
        for (int i = 0; i < 10000; i++) {
            System.out.println(randomNumberLetter(6));
        }
    }

}
